import { message } from 'antd';
 
export const dva = {
  config: {
    onError(err) {
      err.preventDefault();
      message.destroy();
      message.error(err.message)
    },
  },
};

let serveRoutes = [];

export function patchRoutes(routes) {
  routes.forEach(element => {
    //add route
    serveRoutes.map(sr => {
      if (element.path === sr.path) {
        sr.addRoutes.map(srItem => {
          const newRoute = {
            path: srItem.path,
            component: require('./pages' + srItem.path).default,
          };
          element.routes && element.routes.unshift(newRoute);
        });
      }
    });
  });

  window.g_routes = routes;
}

export function render(oldRender) {
  oldRender();
}
